import api from "@/util/api.js";

//查询
async function findall(pageNo=1,pageSize=10,params={}){
    let p = Object.assign({}, params);

    let birthFrom, birthTo;//出生日期的开始和截止
    if (Array.isArray(p.birthdayR)) {
        if (p.birthdayR.length > 0) {
            birthFrom = p.birthdayR[0];
        }
        if (p.birthdayR.length > 1) {
            birthTo = p.birthdayR[1];
        }
        delete p.birthdayR;
    }
    //console.log(birthFrom,birthTo);
    let resp=await api({
        url:"/admin",
        method:"get",
        params:{pageNo,
            pageSize,
            ...p,
            birthTo,
            birthFrom
        }
    });
    //console.log(resp);
    return resp;
}
//删除
async function deleteids(ids){
    let resp=await api({
        url:"/admin",
        method:"delete",
        data:ids
    })
    return resp;
}
//新增
async function addall(adminadd){
    let resp=await api({
        url:"/admin",
        method:"post",
        data:adminadd
    })
    return resp;
}
//修改
async function updateal(adminadd){
    let resp=await api({
        url:"/admin",
        method:"put",
        data:adminadd
    })
    return resp;
}
export {findall,deleteids,addall,updateal}